package com.yztc.ui.home;

import android.content.Context;

import com.yztc.bean.home.HomeFragmentBean;
import com.yztc.ui.home.config.HomeUrlConfig;
import com.yztc.base.OnLoadListener;


/**
 * Created by My on 2016/10/6.
 */
public class HomePresenter implements HomeConstract.IHomePresenter {
    private HomeConstract.IHomeView mHomeView;
    private HomeModle mHomeModle;

    public HomePresenter(HomeConstract.IHomeView mHomeView){
        this.mHomeView = mHomeView;
        this.mHomeModle = new HomeModle();
    }
    @Override
    public void loadData(final Context context) {

        mHomeModle.LoadNewsData(HomeUrlConfig.Path.BASE_URL,new OnLoadListener() {
            @Override
            public void onSuccess(HomeFragmentBean homeFragmentBean){

                mHomeView.addHelloImage(homeFragmentBean.getData().getTopBannerList());
                mHomeView.addToRecAdapter(homeFragmentBean.getData().getListLc());
                mHomeView.addVPImages(homeFragmentBean.getData().getListFocus());
                mHomeView.addProductImages(homeFragmentBean.getData().getUrlProductImage());
                mHomeView.addJingXuanData(homeFragmentBean.getData().getRollList().get(0));
                mHomeView.addShangShiData(homeFragmentBean.getData().getRollList().get(1));
                mHomeView.addFourImages(homeFragmentBean.getData().getNewBannerList());
            }

            @Override
            public void onFailure(Throwable e) {
               mHomeView.showErrorMsg(e);
            }
        });
    }
}
